﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;

namespace NeuroForecast
{
    class Unusing
    {
        //private void But_CreateAlgorithm_Click(object sender, RoutedEventArgs e)
        //{
            //LinearLayer il = new LinearLayer(1);
            //SigmoidLayer hl1 = new SigmoidLayer(100);
            //// SigmoidLayer hl2 = new SigmoidLayer(10);
            //SigmoidLayer ol = new SigmoidLayer(1);

            //new BackpropagationConnector(il, hl1).Initializer = new RandomFunction(0d, 0.3d);
            ////new BackpropagationConnector(hl1, hl2).Initializer = new RandomFunction(0d, 0.3d);
            //new BackpropagationConnector(hl1, ol).Initializer = new RandomFunction(0d, 0.3d);
            //BackpropagationNetwork network = new BackpropagationNetwork(il, ol);
            //network.SetLearningRate(0.25);

            //double x, y;
            //y = 30.1851;

            //TrainingSet ts = new TrainingSet(1, 1);

            //for (DateTime i = new DateTime(2010, 01, 01); i < new DateTime(2011, 01, 01); i = i.AddDays(1))
            //{
            //    x = i.ToBinary();
            //    var results = from myRow in SourceData.AsEnumerable()
            //                  where Convert.ToDateTime(myRow.ItemArray[0]) == i
            //                  select myRow;
            //    if (results.Count() > 0)
            //        y = Convert.ToDouble(results.ElementAt(0).ItemArray[1]);
            //    for (double j = x - 0.05; j < x + 0.05; j += 0.01)
            //    {
            //        ts.Add(new TrainingSample(new double[] {j}, new double[] {y}));
            //    }
            //}

            //network.Learn(ts, 1000);
            //network.StopLearning();

            //MSSQLTools DataBase = new MSSQLTools();
            //DataTable SData = new DataTable();

            //DataBase.ExecuteQuery("BEGIN TRANSACTION");

            //for (int i = 0; i < SData.Rows.Count - 1; i++)
            //{
            //    DateTime dateNow = Convert.ToDateTime(SData.Rows[i][0]);
            //    DateTime dateNext = Convert.ToDateTime(SData.Rows[i + 1][0]);
            //    DateTime dateTemp = dateNow;
            //    TimeSpan st = dateNext - dateNow;
            //    int dif = st.Days;
            //    while (dif > 1)
            //    {
            //        dif--;
            //        dateTemp = dateTemp.AddDays(1);
            //        int obsID;
            //        if (DataBase.ExecuteQuery(
            //            "SELECT id FROM NeuroForecastDB.dbo.Observations WHERE Observation = '" + ConvertDate(dateTemp) +
            //            "'").Rows.Count == 0)
            //        {
            //            DataBase.ExecuteQuery("INSERT INTO NeuroForecastDB.dbo.Observations (Observation) " +
            //                                  "VALUES ('" + ConvertDate(dateTemp) + "');");
            //            int.TryParse(DataBase.ExecuteQuery(
            //                "SELECT id FROM NeuroForecastDB.dbo.Observations WHERE Observation = '" +
            //                ConvertDate(dateTemp) + "'").Rows[0].ItemArray[0].ToString(), out obsID);

            //            int critID = 10;
            //            DataBase.ExecuteQuery("INSERT INTO NeuroForecastDB.dbo.vals (cid, oid, val) " +
            //                                  "VALUES (" + critID + ", " + obsID + ", " +
            //                                  SData.Rows[i][1].ToString().Replace(',', '.') + ")");
            //            critID = 12;
            //            DataBase.ExecuteQuery("INSERT INTO NeuroForecastDB.dbo.vals (cid, oid, val) " +
            //                                  "VALUES (" + critID + ", " + obsID + ", " +
            //                                  SData.Rows[i][2].ToString().Replace(',', '.') + ")");
            //            critID = 13;
            //            DataBase.ExecuteQuery("INSERT INTO NeuroForecastDB.dbo.vals (cid, oid, val) " +
            //                                  "VALUES (" + critID + ", " + obsID + ", " +
            //                                  SData.Rows[i][3].ToString().Replace(',', '.') + ")");
            //        }
            //    }
            //}
            //DataBase.ExecuteQuery("COMMIT TRANSACTION");
        //}
    }
}
